package com.hangan.langchainspringstart.service.impl;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hangan.langchainspringstart.mapper.VolunteerMapper;
import com.hangan.langchainspringstart.model.Volunteer;
import com.hangan.langchainspringstart.service.IVolunteerService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author hang an
 * @since 2025/8/1
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer> implements IVolunteerService {
    @Override
    public Volunteer book(Volunteer volunteer) {
        volunteer.setId(IdUtil.getSnowflakeNextId());
        super.save(volunteer);
        return volunteer;
    }

    @Override
    public Volunteer getByPhone(String phone) {
        return super.getOne(
                Wrappers.<Volunteer>lambdaQuery()
                        .eq(Volunteer::getPhone, phone)
        );
    }
}
